package com.lianjinsu.shop.repository.dao.impl;

import com.lianjinsu.shop.core.mybatis.AdvancedDaoImpl;
import com.lianjinsu.shop.entity.Cart;
import com.lianjinsu.shop.repository.dao.CartDao;
import com.lianjinsu.shop.repository.mapper.CartMapper;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collections;

@Repository
public class CartDaoImpl extends AdvancedDaoImpl<CartMapper, Cart> implements CartDao {

    @Override
    public Cart clearCart(String openid) {
        Cart cart = new Cart();
        cart.setOpenid(openid);
        cart.setShopList(Collections.emptyList());
        cart.setTotalPrice(BigDecimal.ZERO);
        cart.setCreateTime(LocalDateTime.now());
        cart.insertOrUpdate();
        return cart;
    }
}
